<extend name="Index/index"/>

<block name="box">
    <div class="view-product">
        <div class="info-center">
            <div class="manage-head">
                <h6 class="padding-left manage-head-con">{{$title}}</h6>
            </div>
        </div>
        <div class="layui-container" style="margin-top: 20px">
            <div class="layui-row">

                <div class="layui-col-md8 layui-col-md-offset1">
                    <form class="layui-form" action="{{:U('Goods/addImg')}}" method="post" enctype="multipart/form-data" id="myform">
                        <!--商品名称-->
                        <div class="layui-form-item">
                            <h3>{{$name}}</h3>
                        </div>
                        <input type="hidden" name="goods_id" value="{{$goodsImgList[0]['goods_id']}}">
                        <!--商品图片-->
                        <div class="layui-form-item">
                            <label class="layui-form-label">添加图片</label>
                            <div class="layui-input-block">
                                <input type="file" name="photo" required  lay-verify="required"  autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit >添加</button>
                            </div>
                        </div>
                    </form>
                    
                </div>
                <div class="layui-col-md11 layui-col-md-offset1">
                    <div class="panel-body">
                        <div class="row">
                            <if condition="empty($goodsImgList)">
                                <h3 class="text-danger text-center">暂无图片</h3>
                            </if>
                            <foreach name="goodsImgList" item="value">
                                <if condition="$value.is_main == 1">
                                    <div class="col-sm-12 col-md-12">
                                        <div class="col-sm-6 col-md-3">
                                            <div class="thumbnail">
                                                <img src="{{:get_img_url('__ROOT__/Uploads/GoodsImg/',$value['img'],350)}}">
                                                <div class="caption">

                                                        <button class="btn btn-success">封面图</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                <else/>
                                    <div class="col-sm-6 col-md-3">
                                        <div class="thumbnail">
                                            <img src="{{:get_img_url('__ROOT__/Uploads/GoodsImg/',$value['img'],350)}}">
                                            <div class="caption">

                                                    <button class="btn btn-success">不是封面</button>
                                                    <a href="{{:U('Goods/setMain',array('goods_id'=>$goods_id,'id'=>$value['id']))}}" class="btn btn-primary" role="button">设封面</a>
                                                    <br><br>
                                                    <if condition="$value.is_show == 1">
                                                        <a href="{{:U('Goods/setShow',array('goods_id'=>$goods_id,'id'=>$value['id'],'is_show'=>$value['is_show']))}}" class="btn btn-info" role="button">页面间显示</a>
                                                        <else/>
                                                        <a href="{{:U('Goods/setShow',array('goods_id'=>$goods_id,'id'=>$value['id'],'is_show'=>$value['is_show']))}}" class="btn btn-info" role="button">页面间不显示</a>
                                                    </if>

                                                    <a href="{{:U('Goods/delImg',array('goods_id'=>$goods_id,'id'=>$value['id']))}}" class="btn btn-danger" role="button">删除</a>
                                            </div>
                                        </div>
                                    </div>
                                </if>

                            </foreach>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function(data){
                layer.msg(JSON.stringify(data.field));
                return false;
            });
        });

        //如果价格小于等于0 时,就不能提交
        $(function(){
            $("#myform").submit(function(){
                if($("#price").val() <= 0){
                    alert("价格不能小于等于0");
                    return false;
                }else{
                    return true;
                }

            })
        })

    </script>
</block>